package cn.bytecollege.admin.controller;

import cn.bytecollege.admin.service.OrdersService;
import cn.bytecollege.common.constant.Resource;
import cn.bytecollege.common.entity.Orders;
import cn.bytecollege.common.entity.Page;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.rowset.serial.SerialException;
import java.io.IOException;

@WebServlet(name = "OrdersListController",value = "/super/ordersList")
public class OrdersListController   extends HttpServlet {
    private OrdersService ordersService = null;
    public OrdersListController(){ ordersService = new OrdersService();}
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        doPost(request,response);
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        String index = request.getParameter("index");
        int pageIndex = (index==null)?1:Integer.parseInt(index);
        String size =request.getParameter("size");
        int pageSize = (size==null)?10:Integer.parseInt(size);

        Page<Orders> page = ordersService.findOrdersByPage(pageIndex,pageSize);
        //跳转页面
        request.setAttribute("page",page);
        request.getRequestDispatcher("/super/html/device/ordersList.jsp").forward(request,response);
    }
}
